/*******************************************************************************
 * Copyright (c) 2012 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

	 		
	function delChild(fatherName,childName,childId,id,type){
			var fatherNames=document.getElementById(fatherName);
			var childNames=document.getElementById(childName+"_"+id);
			var userLevelStrategyId="";
			var productWomSettingId="";
			var userCreditWomValueId="";
			var pointTemporaryStrategyId="";
			  	if(childId=="userLevelStrategyId"){
						userLevelStrategyId=id;		  
					}
				if(childId=="productWomSettingId"){
						productWomSettingId=id;
					}
				if(childId=="userCreditWomValueId"){
						userCreditWomValueId=id;
					}
				if(childId=="pointTemporaryStrategyId"){
						pointTemporaryStrategyId=id;
					}	
				if(type==null){
						$.ajax({
						 type: "post",
						  url: __ctxPath+"/admin/system/systemParameter.do?cmd=delChild",
						  data:{userLevelStrategyId:userLevelStrategyId,productWomSettingId:productWomSettingId,userCreditWomValueId:userCreditWomValueId,pointTemporaryStrategyId:pointTemporaryStrategyId},
						  cache: false,
						  success: function(msg){
						    if(msg==1){
								fatherNames.removeChild(childNames);
								alert('删除成功！');
							}else{
								alert('该设置已被引用暂不能删除！');
							}
						  }
					  })
					 }else{
						fatherNames.removeChild(childNames);
						alert('删除成功！');
					 }
		}
		
		 var i=1000;
		function addChild(fatherName,childName,childId,value1,value2,value3){
	 		var str="<div style='float:left;width:700px;' id='"+childName+"_"+i+"'>";
	 		str+="<input type='hidden' name='"+childId+"' />";
	 		if(value1!=null){
	 		str+="<p style='float:left;width:100px;'><input style='width:70px;' type='text' name='"+value1+"'/></p>";
	 		}
	 		if(value2!=null){
	 		str+="<p style='float:left;width:100px;'><input style='width:70px;' type='text' name='"+value2+"'/></p>";
	 		}
	 		if(value3!=null){
	 		str+="<p style='float:left;width:100px;'><input style='width:70px;' type='text' name='"+value3+"'/></p>";
	 		}
	 		if(fatherName=="pointTemporaryStrategy"){
	 			str+="<p style='float:left;width:250px;'>从<input id='beginTime"+i+"' name='beginTime'  style='width:100px;'/>到<input id='endTime"+i+"' name='endTime' style='width:100px;'/></p>";
	 			str+="<p style='float:left;width:100px;'><select name='state' id='state'><option value='1'>应用</option><option value='0'>停用</option></select><a href='#' onclick=\"return delChild('"+fatherName+"','"+childName+"','"+childId+"',"+i+",1)\">删除</a></p>";
	 		}else{
	 			str+="<p style='float:left;width:100px;'><a href='#' onclick=\"return delChild('"+fatherName+"','"+childName+"','"+childId+"',"+i+",1)\">删除</a></p>";
	 		}
	 		str+="</div>"
			$(str).appendTo("#"+fatherName);
			$( function() {
				applyDateTime1('beginTime'+i);
				applyDateTime1('endTime'+i);
				});
			i++;
		}	 		